Skip to content

fix(rpc)!: reject keys outside the schema of an eth_getProof answer - #5449

Closed
ilitteri wants to merge 1 commit into
ethereum:masterfrom
lambdaclass:fix/rpc-proof-answer-keys
Closed

ilitteri wants to merge 1 commit into
ethereum:masterfrom
lambdaclass:fix/rpc-proof-answer-keys

Conversation

@ilitteri

@ilitteri ilitteri commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

The reader of an eth_getProof answer rejects an answer or a slot that holds a key outside its schema, where it ignored the key.

The problem

The AccountProof and StorageProof schemas of execution-apis set additionalProperties: false.
So an answer holds only its seven properties, and a slot only key, value and proof.
accountProofOfJson and storageProofOfJson (Execution/Rpc/Proof.lean) read the properties that they know and ignored any other.
So execution.trie.verify_account_proof accepted an answer that the schema does not allow.
The readers of block and account overrides of eth_simulateV1 already follow the same rule of their schemas, with onlyKeys.

The idea

Each reader first checks its keys with onlyKeys, against accountProofKeys or storageProofKeys, the properties of its schema.
onlyKeys reads the raw object, so a key of value null counts too, as it does for the overrides.

  • onlyKeys moves from Execution/Rpc/Simulate.lean to Serialization/JsonRpc.lean, next to fields, so that both callers reach it.
    Its private lemma onlyKeys_rejects moves with it and becomes public.
  • onlyKeys_mkObj states that an object built from pairs with distinct names, each among the keys, passes.
    With it, accountProofOfJson_accountProofJson, the round trip of the reader, keeps its statement.
  • accountProofOfJson_unknown_key and storageProofOfJson_unknown_key state the rejection.

Example

Take the answer of the fixture get-account-proof-with-storage.io at block 60, and add one property:

answer + {"extra": "0x0"}                    before: key ignored   after: "answer: unknown key extra"
answer + {"extra": null}                     before: key ignored   after: "answer: unknown key extra"
a slot + {"extra": "0x0"} in storageProof    before: key ignored   after: "slot: unknown key extra"

Without the extra key, the answer shows one slot that is set, [True], and it still does.

Each rejection is TrieError code 0, the code of every reading error of this export.
test_field_out_of_its_pattern runs the three cases.

For reviewers

  • A key of value null that the schema names, such as "address": null, passes the key check and then fails as a missing field, as before.
  • Only the reader of an answer changes.
    The writer and the node's own answer were already within the schema.
  • The move changes the full name of onlyKeys to EthLib.Serialization.JsonRpc.onlyKeys.
    No module of tests/downstream or the bindings names it.
  • Execution/Proofs/Rpc/Simulate.lean gains a private import of Serialization/Proofs/JsonRpc.lean, for onlyKeys_rejects.

Checks

  • lake build --wfail (whole library, proofs and exports), on b91aea7: passed.
  • lake exe gen-bindings --check: passed.
  • lake exe check-decls: 0 findings.
    lake exe check-accessors, lake exe check-theorems and check_theorems_baseline.py --base upstream/master: passed, nothing new.
  • lake exe proof-coverage --check and lake exe rule-history --check: passed.
  • soundness_facts.py --check, check_layers.py, check_lean_layout.py --base upstream/master, check_comment_code.py, check_lean_commands.py, check_fork_cap.py and check_fixture_pins.py: passed.
  • uv run --no-sync pytest -n auto: 78558 passed, 680 skipped, 13 xfailed.
    check_vectors.py: 2328 pinned vectors match.
  • ruff check, ruff format --check, ty check, check_raises.py, check_docstrings.py, check_python_boundary.py and check_python_comments.py --all: passed.
    codespell ran on the changed test file only.
  • Not run: ty check --python-version 3.10 of the package and the unit tests of scripts/, which this change does not touch, and the build of tests/downstream.
  • check_writing.py --base upstream/master: S1 and D1 suggestions only, the D1 ones on headers this change does not touch.

BREAKING CHANGE: execution.trie.verify_account_proof raises TrieError for an answer or a slot with a key outside its schema.
In Lean, onlyKeys is EthLib.Serialization.JsonRpc.onlyKeys, where it was EthLib.Execution.Rpc.onlyKeys.

The AccountProof and StorageProof schemas of execution-apis set
additionalProperties to false, so an answer or a slot holds no other
property. The reader of an answer read the properties it knows and
ignored any other, so verify_account_proof accepted such an answer.

Both readers now check their keys first with onlyKeys, as the readers
of block and account overrides do. onlyKeys moves next to fields in
Serialization/JsonRpc.lean, with the lemmas onlyKeys_mkObj and
onlyKeys_rejects. The round trip of the reader still holds, and
accountProofOfJson_unknown_key and storageProofOfJson_unknown_key state
the rejection.

BREAKING CHANGE: execution.trie.verify_account_proof raises TrieError
for an answer or a slot with a key outside its schema. In Lean,
onlyKeys is EthLib.Serialization.JsonRpc.onlyKeys, where it was
EthLib.Execution.Rpc.onlyKeys.
tcoratger added a commit that referenced this pull request Dec 4, 2026
…5458)

The reader of an `eth_getProof` answer rejects an answer or a slot that holds a key outside its `AccountProof` or `StorageProof` schema, which set `additionalProperties: false`, where it ignored the key.

`onlyKeys` moves to `Serialization/JsonRpc.lean`, and it and `hasOnly` share one search, `outsideField`.
`accountProofOfJson_unknown_key` and `storageProofOfJson_unknown_key` state the rejection.

Supersedes #5449.

BREAKING CHANGE: `execution.trie.verify_account_proof` raises `TrieError` for an answer or a slot with a key outside its schema.
In Lean, `onlyKeys` is `EthLib.Serialization.JsonRpc.onlyKeys`, where it was `EthLib.Execution.Rpc.onlyKeys`.

Co-authored-by: ilitteri <ivanlitteri@hotmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tcoratger

Copy link
Copy Markdown
Collaborator

Thank you @ilitteri! Pushes to the lambdaclass fork were refused, so this landed as #5458, with your commit unchanged and credited as co-author. The review commit on top only makes onlyKeys and hasOnly share one search, outsideField.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants